package chapter.two.six;

import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class PricesInfo {
	private ReadWriteLock lock;
	private double priceA;
	private double priceB;
	
	public PricesInfo(double priceA, double priceB) {
		this.priceA = priceA;
		this.priceB = priceB;
		lock = new ReentrantReadWriteLock();
	}
	
	public double getPriceA() {
		lock.readLock().lock();
		double value = priceA;
		lock.readLock().lock();
		return value;
	}

	public double getPriceB() {
		lock.readLock().lock();
		double value = priceB;
		lock.readLock().lock();
		return value;
	}



	public void setPrice(double priceA, double priceB) {
		lock.writeLock().lock();
		this.priceA = priceA;
		this.priceB = priceB;
		lock.writeLock().unlock();
	}
	
	
}
